import java.sql.*;
public class Main {
    public static void main(String[] args) {
        Connection connection = null;
        Statement statement  = null;
        try{
            // 1. 获取链接
            connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/bjpowernode","root","1234567899");

            // 2.获取数据库操作对象
            statement = connection.createStatement();

            // 3.执行sql语句
            String sql = "update emp set sal = sal * 0.5 where sal = 3200;";
            int ret = statement.executeUpdate(sql);
            System.out.println(ret);

            // 4.对查询结果集进行处理

        }
        catch (SQLException e)
        {
            e.printStackTrace();
        }finally {
            // 5. 释放资源
            try {
                if(connection!=null)
                {
                    connection.close();
                }

            }
            catch (SQLException e)
            {
                e.printStackTrace();
            }


            try
            {
                if (statement!=null)
                {
                    statement.close();
                }
            }catch (SQLException e)
            {
                e.printStackTrace();
            }
        }
    }
}